cmake_minimum_required(VERSION 3.8)
set(PROJECT_NAME KPT)
project(${PROJECT_NAME})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED FALSE)

set(CSUGL_BUILD_MODEL_LOADER OFF)
set(CSUGL_DIR vendor/CSUGL)
include_directories(${CSUGL_DIR}/src)
add_subdirectory(${CSUGL_DIR})
list(APPEND LIBS CSUGL)

include_directories(vendor/CSUGL/vendor/GLFW/include)
include_directories(vendor/CSUGL/vendor/glad/include)
include_directories(vendor/CSUGL/vendor/glm)
include_directories(vendor/CSUGL/vendor/stb)
include_directories(vendor/CSUGL/vendor/glog/src)
include_directories(vendor/CSUGL/vendor/imgui)
include_directories(vendor/CSUGL/vendor/assimp/include)

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
	# define _CRT_SECURE_NO_WARNINGS in MSVC
	add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
file(GLOB_RECURSE SOURCE_FILES src/*.cpp)
file(GLOB_RECURSE HEADER_FILES src/*.h)
file(GLOB_RECURSE SHADER_FILES assets/shader/*.*)
source_group("Headers" FILES ${HEADER_FILES})
source_group("Sources" FILES ${SOURCE_FILES})
source_group("Shaders" FILES ${SHADER_FILES})
include_directories(./src/)
add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${HEADER_FILES} ${SHADER_FILES})
target_link_libraries(${PROJECT_NAME} ${LIBS})

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
    # As startup project
    set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})
    # copy assets to build
	set(ASSETS_PATH ${CMAKE_SOURCE_DIR}/assets)
	set(TARGET_PATH ${CMAKE_BINARY_DIR})
	message("copy " ${ASSETS_PATH} " to " ${TARGET_PATH})
	add_custom_command(
		TARGET ${PROJECT_NAME} POST_BUILD
		COMMAND ${CMAKE_COMMAND} -E copy_directory ${ASSETS_PATH} ${TARGET_PATH}/assets
		DEPENDS ${PROJECT_SHADERS})
endif()